
import java.io.PrintWriter;

class FunctionDeclaration extends Declaration {

	private Node ftype_;
	private Node type_;
	private Node block_;
	private Node formal_list_;
	private String name_;

	public FunctionDeclaration(Node f, Node t, Node fl, Node b, String n) {
		ftype_ = f;
		type_ = t;
		block_ = b;
		formal_list_ = fl;
		name_ = n;
	}

	public FunctionDeclaration(Node f, Node t, Node b, String n) {
		ftype_ = f;
		type_ = t;
		block_ = b;
		name_ = n;
	}

	@Override
	public void print(PrintWriter pw) {
		pw.println("Node name : FunctionDeclaration. Func name is: " + name_);
		// assert(type_ && block_);
		type_.print(pw);
		if (formal_list_ != null) {
			formal_list_.print(pw);
		}
		block_.print(pw);
	}
	
	public String translate(PrintWriter pw, String strPare) {
		if(((FuncType) ftype_).getType().equals("def")){
			pw.print("public ");
			type_.translate(pw,"");
			pw.print(" "+name_);
			pw.print("(");
			if(formal_list_ != null){
				formal_list_.translate(pw,null);
			}
			pw.print(")");
			block_.translate(pw,null);
		}
	 	return null;	
	}
}

